SRC=$(HOME)/csr-repository
#echo$(SRC)
MAINLIB = $(SRC)/lib/
#INC     = $(SRC)/include/
LIBS    = /usr/local/lib/

LDFLAGS = -lstdc++ 

#BUILD_TYPE=debug
BUILD_TYPE=release

ifeq ($(BUILD_TYPE), debug)
	CFLAGS = ""#$(INC)
endif
ifeq ($(BUILD_TYPE), release)
	# -O3 tells the compiler to optimize which takes more time, however the code is about 50% faster
	CFLAGS = -O3 #$(INC)
endif

TARGET = $(MAINLIB)/libswarm_network.so 
CFILES =../Network.cpp \
	../swarmSocketClient.cpp \
	../swarmSocketServer.cpp \
	../socketTest.cpp \
	../../Algorithms/robotFunctions.cpp

OFILES = *.o

all: $(TARGET)

%.o: ../%.cpp
	gcc -c $(CFLAGS) $(CFILES)



$(MAINLIB)/libswarm_network.so: $(OFILES)
	gcc -shared -o $(TARGET) $(LDFLAGS) $+
	sudo ln -sf $(TARGET) --target-directory=$(LIBS)
	sudo ldconfig /usr/local/lib/


clean:	
	rm -f *.o
	rm -f *.d
